﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SistemaVarejo.Model;
using System.Data.Entity;
using System.Data;

namespace SistemaVarejo.DAO
{
    class VendedorDAO
    {
        public static bool incluir(Vendedor v){
            VarejoEntities db = SingletonObjectContext.Instance.Context;
            try
            {
                db.Vendedor.Add(v);
                db.SaveChanges();
                return true;
            }
            catch{
                return false;
            }
        }

        public static Vendedor ConsultaNome(Vendedor v) {
            VarejoEntities db = SingletonObjectContext.Instance.Context;
            try {
                v = db.Vendedor.FirstOrDefault(x => x.nome.Equals(v.nome));
                return v;
            }
            catch
            {
                return null;
            }
        }

        public static Vendedor ConsultaCpf(Vendedor v) {
            VarejoEntities db = SingletonObjectContext.Instance.Context;
            try
            {
                v = db.Vendedor.FirstOrDefault(x => x.cpf.Equals(v.cpf));
                return v;
            }
            catch {
                return null;
            }
        
        }





    }
}
